//
//  UserCancelAgreementVC.m
//  Project_IOS
//
//  Created by topnet on 2022/4/7.
//

#import "UserCancelAgreementVC.h"
#import "UserCancelVC.h"
#import <Masonry/Masonry.h>
#import "LoginTools.h"
@interface UserCancelAgreementVC ()

@end

@implementation UserCancelAgreementVC

- (void)viewDidLoad {
    self.navTitle = @"注销协议";
    self.urlStr = @"http://meme-labs.com/apps/cloudalbum/AccountAggrement.html";
    [super viewDidLoad];
    
    [self.view addSubview:self.buttonView];
    self.buttonView.btnStr = @"下一步";
    [self.leftBarBuBtn addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
}

- (void)dismiss {
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    CGFloat safeBottom = 20;
    if (self.view.safeAreaInsets.bottom > 10) {
        safeBottom = self.view.safeAreaInsets.bottom;
    }
    [self.buttonView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(311, 48));
            make.centerX.mas_equalTo(0);
            make.bottom.mas_equalTo(self.view.mas_bottom).offset(-safeBottom);
    }];
    
    
    
    [self.webV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0 + 44);
        make.left.right.equalTo(@0);
        make.bottom.equalTo(self.buttonView.mas_top).offset(-20);
    }];
}

- (void)nextStep {
    if (LoginTools.currentLoginUser.is_guest) {
        [LoginTools loginOut:^{
            [self dismiss];
        }];
        return;
    }
    ///注销账号
    UserCancelVC *vc = [UserCancelVC new];
    [self.navigationController pushViewController:vc animated:YES];
    
}

- (BlueButtonView *)buttonView {
    if (!_buttonView) {
        _buttonView = [[BlueButtonView alloc] init];
        [_buttonView.button addTarget:self action:@selector(nextStep) forControlEvents:UIControlEventTouchUpInside];
    }
    return _buttonView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
